#!/usr/bin/env python3
import sys
import os
from datetime import datetime

sys.path.insert(0, os.path.dirname(__file__))

from idea_proxy import IDEAProxy
from dashboard import ProxyDashboard

# 创建代理实例
proxy = IDEAProxy('127.0.0.1', 8080)

# 添加测试数据
proxy.requests_log.append({
    'timestamp': datetime.now().isoformat(),
    'client_addr': '127.0.0.1:12345',
    'method_line': 'GET https://plugins.jetbrains.com/api/plugins HTTP/1.1',
    'headers': {
        'User-Agent': 'IntelliJ IDEA/2023.3',
        'Host': 'plugins.jetbrains.com',
        'Accept': 'application/json'
    },
    'raw_request': 'GET https://plugins.jetbrains.com/api/plugins HTTP/1.1\nUser-Agent: IntelliJ IDEA/2023.3'
})

# 启动dashboard
dashboard = ProxyDashboard(proxy, 8081)
dashboard.start()

print("Dashboard已启动: http://localhost:8081")
print("按任意键退出...")
input()
dashboard.stop()